package com.demo.util;

import java.util.concurrent.CountDownLatch;

public class CountDownLatchDemo {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch count = new CountDownLatch(6);
        for (int i = 1; i <= 5; i++) {
            new Thread(()->{
                System.out.println(Thread.currentThread().getName()+":go out");
                //数量-1
                count.countDown();
            },String.valueOf(i)).start();
        }
        //等待计数器归零
        count.await();
        System.out.println("close door");
    }
}
